package com.youku.utils
{
   public class LayoutHelper extends Object
   {
      
      public function LayoutHelper() {
         super();
      }
      
      public static function setVisible(param1:Object, param2:Boolean) : void {
         if(param1 != null)
         {
            param1.visible = param2;
         }
      }
      
      public static function integerLayout(param1:*) : void {
         param1.x = Math.round(param1.x);
         param1.y = Math.round(param1.y);
      }
      
      public static function samePosition(param1:Object, param2:Object) : void {
         param2.x = param1.x;
         param2.y = param1.y;
      }
      
      public static function position(param1:Object, param2:Object, param3:String, param4:Number = 0) : void {
         switch(param3)
         {
            case "top":
               param2.y = param1.y - param2.height - param4;
               break;
            case "left":
               param2.x = param1.x - param2.width - param4;
               break;
            case "bottom":
               param2.y = param1.y + param1.height + param4;
               break;
            case "right":
               param2.x = param1.x + param1.width + param4;
               break;
         }
      }
      
      public static function size(param1:Object, param2:Number, param3:Number) : void {
         param1.width = param2;
         param1.height = param3;
      }
      
      public static function padding(param1:Object, param2:Object, param3:String, param4:Number = 0, param5:Number = 0) : void {
         switch(param3.toLowerCase())
         {
            case "tl":
               param2.x = param1.x + param4;
               param2.y = param1.y + param5;
               break;
            case "tr":
               param2.x = param1.width - param5 - param2.width;
               param2.y = param1.y + param5;
               break;
            case "bl":
               param2.x = param1.x + param4;
               param2.y = param1.y - param5 - param2.height;
               break;
            case "br":
               param2.x = param1.width - param5 - param2.width;
               param2.y = param1.y - param5 - param2.height;
               break;
         }
      }
      
      public static function align(param1:Object, param2:Object, param3:String, param4:Number = 0) : void {
         switch(param3)
         {
            case "top":
               param2.y = param1.y + param4;
               break;
            case "left":
               param2.x = param1.x + param4;
               break;
            case "bottom":
               param2.y = param1.y + param1.height - param2.height - param4;
               break;
            case "right":
               param2.x = param1.x + param1.width - param2.width - param4;
               break;
         }
      }
      
      public static function center(param1:Array, param2:String) : void {
         var _loc3_:String = null;
         var _loc4_:String = null;
         switch(param2)
         {
            case "horizontal":
               _loc3_ = "y";
               _loc4_ = "height";
               break;
            case "vertical":
               _loc3_ = "x";
               _loc4_ = "width";
               break;
            default:
               return;
         }
         var _loc5_:Object = param1[0];
         var _loc6_:* = 1;
         while(_loc6_ < param1.length)
         {
            param1[_loc6_][_loc3_] = _loc5_[_loc3_] + _loc5_[_loc4_] / 2 - param1[_loc6_][_loc4_] / 2;
            _loc6_++;
         }
      }
      
      public static function fixLayout(param1:Object) : void {
         param1.x = Math.round(param1.x);
         param1.y = Math.round(param1.y);
      }
      
      public static function fixLayoutList(param1:Array) : void {
         var _loc2_:Object = null;
         for each(_loc2_ in param1)
         {
            fixLayout(_loc2_);
         }
      }
      
      public static function alignTopLeft(param1:Object, param2:Object) : void {
         param1.x = param2.x;
         param1.y = param2.y;
      }
      
      public static function moveTo(param1:Object, param2:Number = 0, param3:Number = 0) : void {
         param1.x = param2;
         param1.y = param3;
      }
   }
}
